package com.yonyou.pmclouds.workflow.extend.impl;

import com.yonyou.pmclouds.basecom.consts.BillTypeConst;
import com.yonyou.pmclouds.basecom.entity.SuperVO;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.procedure.entity.ProcedureVO;
import com.yonyou.pmclouds.procedure.rmiitf.ProcedureQuery;
import com.yonyou.pmclouds.processinspect.entity.ProcedureInspectVO;
import com.yonyou.pmclouds.workflow.service.rmiitf.IProcessVariableExtendService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 工序报验添加工序名称
 * @author zhangzhonghao
 */
@Component
@Slf4j
public class ProcedureInspectVariableExtendServiceImpl implements IProcessVariableExtendService{

    @Autowired
    private ProcedureQuery procedureQuery;

    @Override
    public void extendProcessVariable(SuperVO businessVO) throws BusinessException {
        if(businessVO == null){
            return;
        }
        ProcedureInspectVO procedureInspectVO = (ProcedureInspectVO) businessVO;

        // 填充工序名称，审批流分支条件用
        String pkProcedure = procedureInspectVO.getPk_procedure();
        ProcedureVO procedureVO = procedureQuery.getById(pkProcedure);
        procedureInspectVO.setProcedure_name(procedureVO.getSname());
    }

    @Override
    public String getBillType() {
        return BillTypeConst.PROCEDUREINSPECT_BILLTYPE;
    }
}
